安装php Error

文章目录
  1. 1. 配置yum源
  2. 2. 安装
    1. 2.1. 这一步就报错了
    2. 2.2. 解决方法
  3. 3. php版本查看
  4. 4. 查看php拓展
  5. 5. 启动php-fpm
  6. 6. pecl安装php拓展

php71w-common conflicts with php-common-5.4.16-43.el7_4.1.x86_64,这个问题困惑许久,查找资料,大部分都说指定安装的版本即可解决,本人亲测无用

配置yum源

1
2
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装

1
yum -y install php71w-devel php71w-fpm
这一步就报错了
1
2
3
Error: php71w-common conflicts with php-common-5.4.16-43.el7_4.1.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
解决方法
1
yum remove  php-common-5.4.16-43.el7_4.1.x86_64

一行代码直接解决

php版本查看

1
2
3
4
 php -v
PHP 7.1.16 (cli) (built: Mar 30 2018 07:40:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

查看php拓展

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
json
libxml
openssl
pcntl
pcre
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
tokenizer
xml
zip
zlib
[Zend Modules]

启动php-fpm

1
systemctl start php-fpm.service

pecl安装php拓展

1.安装pecl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# curl -o go-pear.php http://pear.php.net/go-pear.phar
# php go-pear.php
//查看pecl是否安装成功
#pecl -V
Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249
...
//解决办法
#vim /usr/bin/pecl
//找到下面这句
---------------------------------------------------------------------------------------------------------------------------------------------
exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"
---------------------------------------------------------------------------------------------------------------------------------------------
//去掉-n
# pecl -V
PEAR Version: 1.10.5
PHP Version: 7.1.8
Zend Engine Version: 3.1.0
Running on: Linux localhost.localdomain 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64

2.安装mongodb

1
2
3
4
5
pecl install mongodb
//编译的时候很可能会报错
error:Cannot find OpenSSL's <evp.h>
//解决办法
yum -y install openssl-devel openssl pkgconfig

最后修改配置文件php.ini ,添加一句

1
extension=mongodb.so

php.ini 默认路径在/etc/php.ini

评论